package com.hy.study.driver;

import com.hy.study.bean.JoinTableBean;
import com.hy.study.mapper.JoinTableMapper;
import com.hy.study.reduce.JoinTableReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * @author huyong
 * @date 2024 年 02 月 06 日 14:34: 50
 */
public class JoinTableDriver {
    public static void main(String[] args) throws Exception {
        final String inputfile = "F:\\study\\Hadoop\\input\\join";
        final String outputfile = "F:\\study\\Hadoop\\output\\result4";
        Job job = Job.getInstance(new Configuration());

        job.setJarByClass(JoinTableDriver.class);

        job.setMapperClass(JoinTableMapper.class);
        job.setReducerClass(JoinTableReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(JoinTableBean.class);

        job.setOutputKeyClass(JoinTableBean.class);
        job.setOutputValueClass(NullWritable.class);

        FileInputFormat.addInputPath(job, new Path(inputfile));
        FileOutputFormat.setOutputPath(job, new Path(outputfile));

        boolean completion = job.waitForCompletion(true);
        System.exit(completion ? 1 : 0);
    }
}
